//
//  PCOpusDeatilStore.m
//  PhotoCircle
//
//  Created by Mac_zzt on 15/12/21.
//  Copyright © 2015年 wujungao. All rights reserved.
//

#import "PCOpusDeatilStore.h"
#import "GMHTTPSessionManager.h"
#import "PCUserGameModel.h"

static NSString *opusDeatil_Path         = @"/api/v1/my/game/show.json";
@implementation PCOpusDeatilStore

+ (instancetype)sharedOpusDeatilStore
{
    static PCOpusDeatilStore *store = nil;
    static dispatch_once_t once = 0;
    dispatch_once(&once, ^{
        store = [[PCOpusDeatilStore alloc] init];
    });
    return store;
}

#pragma mark -参赛作品详情
-(void)requestUserGameDataWith:(NSDictionary*)paramDic
                successHandler:(successData)responSuccess
                     otherCode:(code)responCode
                  errorHandler:(failedData)responError
{
    NSString *requestUrl = SERVER_URL(opusDeatil_Path);
    [[GMHTTPSessionManager shared] GET:requestUrl parameters:paramDic success:^(NSURLSessionDataTask * _Nonnull task, id  _Nonnull responseObject) {
        
        NSUInteger responseCode = [responseObject[@"code"] integerValue];
        if (responseObject[@"data"]==[NSNull null]) {
            return ;
        }
        PCUserGameModel *userGameModel;
        if (responseCode == API_RESPONSE_OK) {
            userGameModel = [[PCUserGameModel alloc] initWithDictionary:responseObject[@"data"]];
        }
        responSuccess(userGameModel);
        responCode(responseCode);
    } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
        NSLog(@"error:%@",error);
        responError(error);
    }];
}

@end
